package com.jkt.rms.commons.utils;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.beanutils.BeanUtils;

import com.jkt.rms.business.SystemRole;
import com.jkt.rms.constants.IConstants;
import com.jkt.rms.vo.ResourceRoleVO;
import com.jkt.rms.vo.SystemRoleVO;


public final class EqualityUtils<T> {

	
	private EqualityUtils() {
		// disabled
	}

	/**
	 * Compares two objects using their <tt>equals</tt> method, returning true
	 * if they are equal or both null.
	 * 
	 * @return true if both are identical; true if both are null; true if both
	 *         are not null and both are equal; false if only one of them is
	 *         null; false if they are not equal.
	 */
	public static boolean equals(Object a, Object b) {
		// n.b. also implies "if (a == null && b == null)" is true
		if (a == b) {
			return true;
		}
		return a != null && b != null && a.equals(b);
	}

	/**
	 * Compares two objects using their <tt>equals</tt> method, returning true
	 * if they are equal and both not null.
	 * 
	 * @return true if both are not null and both are equal; false if either or
	 *         both are null; false if they are not equal.
	 */
	public static boolean equalsIfNotNull(Object a, Object b) {
		if (a == null || b == null) {
			return false;
		}
		return a.equals(b);
	}
	
	public static void  copyProperties(Object trg,Object src) throws RMSException
	{
		try {
			BeanUtils.copyProperties(trg, src);
		} catch (IllegalAccessException e) {
			//TO DO 
		} catch (InvocationTargetException e) {
			// TODO Logger
		}
	}
	
	public static boolean isNull(String str){
		if(str == null || "".equals(str)){
			return true;
		}
		return false;
	}
	
	public static boolean isNotNull(String str){
		if(str != null && !"".equals(str)){
			return true;
		}
		return false;
	}
}
